*RESPONSE BIAS (WITH CHRIS BOLLINGER), INITIAL ORG PROGRAM FOR 2009 REVISION;
*CREATE ECO.RESPOND SAS FILE FROM ECO.DAT9808 SAS FILE;

OPTIONS NOCENTER LS=80 PS=500 ;
LIBNAME  ECO  'C:\CPS\WORK';
LIBNAME  UK  'C:\RES\BOLLINGER\UK';

DATA RESPOND; SET ECO.DAT9808;

IF (1 LE CLASS LE 5); * RETAIN WAGE AND SALARY ONLY;

IF RLINENO=. OR LINENO=. THEN DELETE;
IF RLINENO=LINENO THEN PROXY=0; ELSE PROXY=1; * PROXY IF RESPONDENT DIFFERS FROM PERSON RECORD;
IF PROXY=1 AND (RLINENO=SLINENO) THEN SPOUSEPROX=1; ELSE SPOUSEPROX=0; * PROXY AND RESPONDENT LINE NO. EQUALS SPOUSE OF REFERENCE LINENO. ;
IF PROXY=1 AND SPOUSEPROX=0 THEN NSPOUSEPROX=1; ELSE NSPOUSEPROX=0;

WT = EARNWT/120000; * 4 IMPLICIT DECIMAL PLACES IN EARNWT BEGINNING 1994;

***************************************************************;
*          CREATE WAGE VARIABLE                               *;
***************************************************************;

* SET TO PARETO MEANS (COMPILED WITHOUT IMPUTED EARNERS) FOR THOSE AT EARNINGS CAP;
*MEN;
   IF YEAR EQ 98 AND FEMALE EQ 0 AND WKEARN GE 2885 THEN CAPEARN = 4771.90 ;
   IF YEAR EQ 99 AND FEMALE EQ 0 AND WKEARN GE 2885 THEN CAPEARN = 4826.76 ;
  IF YEAR EQ 100 AND FEMALE EQ 0 AND WKEARN GE 2885 THEN CAPEARN = 4901.56 ;
  IF YEAR EQ 101 AND FEMALE EQ 0 AND WKEARN GE 2885 THEN CAPEARN = 4991.66 ;
  IF YEAR EQ 102 AND FEMALE EQ 0 AND WKEARN GE 2885 THEN CAPEARN = 5032.82 ;
  IF YEAR EQ 103 AND FEMALE EQ 0 AND WKEARN GE 2885 THEN CAPEARN = 5064.82 ;
  IF YEAR EQ 104 AND FEMALE EQ 0 AND WKEARN GE 2885 THEN CAPEARN = 5165.54 ;
  IF YEAR EQ 105 AND FEMALE EQ 0 AND WKEARN GE 2885 THEN CAPEARN = 5210.63 ;
  IF YEAR EQ 106 AND FEMALE EQ 0 AND WKEARN GE 2885 THEN CAPEARN = 5267.33 ;
  IF YEAR EQ 107 AND FEMALE EQ 0 AND WKEARN GE 2885 THEN CAPEARN = 5258.63 ;
  IF YEAR EQ 108 AND FEMALE EQ 0 AND WKEARN GE 2885 THEN CAPEARN = 5409.15 ; 

*WOMEN;
   IF YEAR EQ 98 AND FEMALE EQ 1 AND WKEARN GE 2885 THEN CAPEARN = 4462.04 ;
   IF YEAR EQ 99 AND FEMALE EQ 1 AND WKEARN GE 2885 THEN CAPEARN = 4455.18 ;
  IF YEAR EQ 100 AND FEMALE EQ 1 AND WKEARN GE 2885 THEN CAPEARN = 4521.46 ;
  IF YEAR EQ 101 AND FEMALE EQ 1 AND WKEARN GE 2885 THEN CAPEARN = 4569.19 ;
  IF YEAR EQ 102 AND FEMALE EQ 1 AND WKEARN GE 2885 THEN CAPEARN = 4576.93 ;
  IF YEAR EQ 103 AND FEMALE EQ 1 AND WKEARN GE 2885 THEN CAPEARN = 4580.48 ;
  IF YEAR EQ 104 AND FEMALE EQ 1 AND WKEARN GE 2885 THEN CAPEARN = 4613.50 ;
  IF YEAR EQ 105 AND FEMALE EQ 1 AND WKEARN GE 2885 THEN CAPEARN = 4668.51 ;
  IF YEAR EQ 106 AND FEMALE EQ 1 AND WKEARN GE 2885 THEN CAPEARN = 4763.72 ;
  IF YEAR EQ 107 AND FEMALE EQ 1 AND WKEARN GE 2885 THEN CAPEARN = 4779.73 ;
  IF YEAR EQ 108 AND FEMALE EQ 1 AND WKEARN GE 2885 THEN CAPEARN = 4834.32 ; 

IF (YEAR GE 98) AND (WEEKTOP=1 OR WKEARN GE 2885) THEN WKEARN = CAPEARN;

* REAL WAGE/EARNINGS IN FULL-YEAR 2008 DOLLARS (2153);
* WAGE1 IS IMPLICIT EARNINGS/HOURS WAGE FOR ALL;
* WAGE2 IS HOURLY WAGE FOR HOURLY WORKERS W/0 TCO AND IMPLICIT WAGE FOR OTHERS;
* WAGE3 IS HOURLY WAGE FOR HOURLY WORKERS W/O TCO, IMPLICIT FOR OTHERS, EXCLUDES SALARIED WORKERS;

IF WKEARN>0; * CREATE IMPLIED WAGE MEASURE FOR ALL, SUBSET OF HOURLY WORKER WAGE;
IF (WKHOURS=-4 & HRSLSTWK>0) OR WKHOURS>0; * DELETE 0 OR NONVALID WEEKLY HOURS FOR IMPLIED WAGE CALCULATION;

* CALCULATION OF WAGE1;
IF WKHOURS>0 THEN WAGE1=WKEARN/WKHOURS; ELSE WAGE1=WKEARN/HRSLSTWK;
RWAGE1   = WAGE1 * (2153/CPI_83); *REAL WAGE 2008 DOLLARS USING MONTHLY CPI ;
RWKEARN = WKEARN*(2153/CPI_83); *REAL WAGE 2008 DOLLARS USING MONTHLY CPI ;
LRWAGE1=LOG(RWAGE1);

/* HOURLY WAGE IGNORING TIPS AND OVERTIME;
* CALCULATION OF WAGE2;
IF HRWAGE>0 THEN WAGE2=HRWAGE/100;
 ELSE WAGE2=WAGE1; * USE HOURLY WAGE FOR ALL HOURLY WORKERS, IMPLICIT WAGE FOR REST;
RWAGE2   = WAGE2 * (2153/CPI_83); *REAL WAGE JAN08 DOLLARS USING MONTHLY CPI ;
LRWAGE2=LOG(RWAGE2);
*/

* CALCULATION OF HOURLY WAGE2 INCLUDING TIPS, OVERTIME, COMMISSION;
WAGE2=.;
IF (HRWAGE=. OR HRWAGE=0)THEN WAGE2=WAGE1; *SALARIED WORKERS;
IF HRWAGE>0 AND TIPWEARN GE 0 THEN WAGE2=WAGE1; *HOURLY WORKERS WITH TIPS, OVERTIME;
IF HRWAGE>0 AND TIPWEARN=0 THEN WAGE2=HRWAGE/100; *HOURLY WORKERS W/O TIPS, OVERTIME;
* USE HOURLY WAGE FOR HOURLY WORKERS W/O TCO, IMPLICIT WAGE FOR REST;
RWAGE2   = WAGE2 * (2153/CPI_83); *REAL WAGE JAN08 DOLLARS USING MONTHLY CPI ;
LRWAGE2=LOG(RWAGE2);

* DELETES ON EXTREME WAGES USING REAL WAGE1 AND WAGE2;
* NOMINAL $2.13 MW FOR TIPPED WORKERS, BUT WAGE2 INCLUDES TIPS, NO HIGH DELETE GIVEN 99.99 TOPCODE;
IF RWAGE1 LT 3 OR RWAGE1 GT 150 THEN DELETE;
IF RWAGE2 LT 3 OR RWAGE2 GT 150 THEN DELETE;
 *DELETE EXTREME VALUES FOR SALARIED WORKERS (150 ROUGHLY EARNINGS CAP AT 32 HOURS);

WAGE3=.; RWAGE3=.; LRWAGE3=.; * INITIAL SETTINGS;
* CALCULATION OF WAGE3 FOR HOURLY WORKERS;
IF HRWAGE>0 THEN DO;
*CREATE WAGE3 MEASURES FOR HOURLY WORKERS ONLY AND SET NONHOURLY TO MISSING;
WAGE3=WAGE2;
RWAGE3=RWAGE2;
LRWAGE3=LRWAGE2;
END;

* IMPUTATION FLAGS;
IF A_WKEARN=1 THEN IMPUTE1=1; ELSE IMPUTE1=0; * IMPUTATION FLAG BASED ON IMPLICIT WAGE;

IMPUTE2=0; * INITIAL SETTING FOR ALL;
IF (HRWAGE>0) AND TIPWEARN=0 AND A_HRWAGE=1 THEN IMPUTE2=1; *IMPUTATION FLAG BASED ON HOURLY WAGE;
IF (HRWAGE>0) AND TIPWEARN>0 AND A_WKEARN=1 THEN IMPUTE2=1; *IMPUTATION FLAG BASED ON IMPLICIT WAGE;
IF (HRWAGE=. OR HRWAGE=0) AND A_WKEARN=1 THEN IMPUTE2=1; *IMPUTATION FLAG BASED ON IMPLICIT WAGE;

IMPUTE3=. ; * SET MISSING FOR SALARIED WORKERS;
IF (HRWAGE>0) AND TIPWEARN=0 AND A_HRWAGE=1 THEN IMPUTE3=1; *IMPUTATION FLAG BASED ON HOURLY WAGE;
IF (HRWAGE>0) AND TIPWEARN>0 AND A_WKEARN=1 THEN IMPUTE3=1; *IMPUTATION FLAG BASED ON IMPLICIT WAGE;
IF (HRWAGE>0) AND IMPUTE3=. THEN IMPUTE3=0; *SET TO ZERO HOURLY NON-IMPUTES;

********************************;
IF YEAR LE 102 THEN DO;
HISPANIC=.;
IF (1 LE HISPSTAT LE 7) THEN HISPANIC=1;
IF HISPSTAT=8 THEN HISPANIC=0;
IF HISPSTAT=9 THEN HISPANIC=0; * SET DON'T KNOWS TO 0 RATHER THAN .5;
IF HISPANIC=. THEN HISPANIC=0;
END;

IF YEAR GE 103 THEN DO;
IF (1 LE HISPSTAT LE 5) THEN HISPANIC=1; ELSE HISPANIC=0;
END;

* RACE/ETHNICITY;
IF HISPANIC=0 AND RACE=1 THEN WHITE=1; ELSE WHITE=0;
IF HISPANIC=0 AND RACE=2 THEN BLACK=1; ELSE BLACK=0;
IF HISPANIC=0 AND RACE=4 THEN ASIAN=1; ELSE ASIAN=0;
IF HISPANIC=0 AND (RACE=3 OR RACE GE 5) THEN OTHER=1; ELSE OTHER=0; * AFTER 2003 OTHER INCLUDES MIXED;

IF (1 LE CITIZEN LE 3) THEN FOREIGN=0; ELSE FOREIGN=1; * FOREIGN BORN CITIZEN AND NON-CITIZEN;
IF FOREIGN=1 AND CITIZEN=4 THEN FOR_CTZ=1; ELSE FOR_CTZ=0;
IF FOREIGN=1 AND CITIZEN=5 THEN FOR_NONCTZ=1; ELSE FOR_NONCTZ=0;

* _SCHOOL VAR CONVERTS DEGREE TO YEARS 0-20;
EXP1=AGE-_SCHOOL-6; * POTENTIAL EXPERIENCE;
EXP2=AGE-16;
EXP=MIN(EXP1,EXP2);
IF EXP LE 0 THEN EXP=0; ELSE EXP=EXP;
EXPSQ=EXP**2;
EXPCUB=EXP**3;
EXPQUAR=EXP**4;

************PART-TIME STATUS**********;
* DEFINE PT/FT BASED ON USUAL HOURS;
* IF MISSING OR VARIABLE HOURS, BASE ON BLS-DEFINED USUAL STATUS;
* IF STILL MISSING BASE ON HOURS LAST WEEK;
PT=.;
IF (1 LE WKHOURS LT 35) THEN PT=1;
IF WKHOURS GE 35 THEN PT=0;
IF PT=. & YEAR GE 94 AND (4 LE BLSFULL LE 6) THEN PT=1;
IF PT=. & YEAR GE 94 AND (1 LE BLSFULL LE 3) THEN PT=0;
IF PT=. & HRSLSTWK LT 35 THEN PT=1;
IF PT=. & HRSLSTWK GE 35 THEN PT=0;
IF PT=. THEN DELETE;
**************************************;
*CREATE SIZE VARIABLES FROM MSASIZE (2 TO 7);
IF MSASIZE=. THEN SIZE1=1; ELSE SIZE1=0;
IF MSASIZE=2 THEN SIZE2=1; ELSE SIZE2=0;
IF MSASIZE=3 THEN SIZE3=1; ELSE SIZE3=0;
IF MSASIZE=4 THEN SIZE4=1; ELSE SIZE4=0;
IF MSASIZE=5 THEN SIZE5=1; ELSE SIZE5=0;
IF MSASIZE=6 THEN SIZE6=1; ELSE SIZE6=0;
IF MSASIZE=7 THEN SIZE7=1; ELSE SIZE7=0;

IF 10<STATE<20 THEN NE=1; ELSE NE=0;
IF 20<STATE<30 THEN MA=1; ELSE MA=0;
IF 30<STATE<40 THEN ENC=1; ELSE ENC=0;
IF 40<STATE<50 THEN WNC=1; ELSE WNC=0;
IF 50<STATE<60 THEN SA=1; ELSE SA=0;
IF 60<STATE<70 THEN ESC=1; ELSE ESC=0;
IF 70<STATE<80 THEN WSC=1; ELSE WSC=0;
IF 80<STATE<90 THEN MT=1; ELSE MT=0;
IF 90<STATE<100 THEN PAC=1; ELSE PAC=0;

IF DEGREE=31 THEN SCH_NONE=1; ELSE SCH_NONE=0;
IF DEGREE=32 THEN SCH1_4=1; ELSE SCH1_4=0;
IF DEGREE=33 THEN SCH5_6=1; ELSE SCH5_6=0;
IF DEGREE=34 THEN SCH7_8=1; ELSE SCH7_8=0;
IF DEGREE LE 34 THEN ED_ELEM=1; ELSE ED_ELEM=0;
IF DEGREE=35 THEN SCH_9=1; ELSE SCH_9=0;
IF DEGREE=36 THEN SCH_10=1; ELSE SCH_10=0;
IF DEGREE=37 THEN SCH_11=1; ELSE SCH_11=0;
IF DEGREE=38 THEN SCH_12=1; ELSE SCH_12=0;
IF PEDIPGED=2 THEN GED=1; ELSE GED=0;
IF DEGREE=39 AND GED=0 THEN SCH_HS=1; ELSE SCH_HS=0;
IF DEGREE=39 THEN ED_HS=1; ELSE ED_HS=0;
IF DEGREE=40 THEN SCH_SOME=1; ELSE SCH_SOME=0;
IF DEGREE=41 THEN SCH_AS1=1; ELSE SCH_AS1=0;
IF DEGREE=42 THEN SCH_AS2=1; ELSE SCH_AS2=0;
IF (41 LE DEGREE LE 42) THEN ED_ASSOC=1; ELSE ED_ASSOC=0;
IF DEGREE=43 THEN SCH_BA=1; ELSE SCH_BA=0;
IF DEGREE=44 THEN SCH_MA=1; ELSE SCH_MA=0;
IF DEGREE=45 THEN SCH_PRO=1; ELSE SCH_PRO=0;
IF DEGREE=46 THEN SCH_PHD=1; ELSE SCH_PHD=0;

IF DEGREE LE 38 THEN DROPOUT=1; ELSE DROPOUT=0;
IF DEGREE GE 44 THEN GRAD_DEG=1; ELSE GRAD_DEG=0;

VET=0;
IF YEAR LE 2003 AND (1 LE VETERAN LE 5) THEN VET=1; * VETERAN=6 IS NOT SERVED;
IF YEAR GE 2004 AND VETERAN=1 THEN VET=1; * VETERAN=2 IS NOT SERVED;
* NOTE: THROUGH 2003 USED PERIOD OF SERVICE VARIABLE (133-134), STARTING 2004 USED WHETHER SERVED (131-132);

IF CENTRAL=. THEN CENTRAL=0;
IF CENTRAL GE 1 THEN CENTRAL=1;

IF AGE LE 25 THEN YOUNG=1; ELSE YOUNG=0;
IF AGE GE 60 THEN OLD=1; ELSE OLD=0;

IF MIS=4 THEN YEAR1=1; ELSE YEAR1=0;
IF MONTH=2 THEN FEB=1; ELSE FEB=0;
IF MONTH=3 THEN MARCH=1; ELSE MARCH=0;
IF MONTH=1 OR MONTH GE 4 THEN OTHERMONTH=1; ELSE OTHERMONTH=0;

IF YEAR= 98 THEN YEAR98=1; ELSE YEAR98=0;
IF YEAR= 99 THEN YEAR99=1; ELSE YEAR99=0;
IF YEAR=100 THEN YEAR100=1; ELSE YEAR100=0;
IF YEAR=101 THEN YEAR101=1; ELSE YEAR101=0;
IF YEAR=102 THEN YEAR102=1; ELSE YEAR102=0;
IF YEAR=103 THEN YEAR103=1; ELSE YEAR103=0;
IF YEAR=104 THEN YEAR104=1; ELSE YEAR104=0;
IF YEAR=105 THEN YEAR105=1; ELSE YEAR105=0;
IF YEAR=106 THEN YEAR106=1; ELSE YEAR106=0;
IF YEAR=107 THEN YEAR107=1; ELSE YEAR107=0;
IF YEAR=108 THEN YEAR108=1; ELSE YEAR108=0;

**********************************************************;
* CREATE CLASS AND INDUSTRY SECTOR VARIABLES BASED ON PUBLIC SECTORS AND PRIVATE SECTORS;
*INDUSTRY AND SECTOR PRE-2003 (BEGINNING 1994 WHEN NONPROFIT INTRODUCED);

IF YEAR LE 102 THEN DO;

IF CLASS=1 AND IND3 NE 412 THEN PUB_FED=1; ELSE PUB_FED=0;
IF CLASS=1 AND IND3 EQ 412 THEN PUB_USPS=1; ELSE PUB_USPS=0;
IF CLASS=2 THEN PUB_STATE=1; ELSE PUB_STATE=0;
IF CLASS=3 THEN PUB_LOCAL=1; ELSE PUB_LOCAL=0;
IF CLASS=5 THEN NONPROFIT=1; ELSE NONPROFIT=0;
PUB_FEDALL=PUB_FED+PUB_USPS; *COMBINE POSTAL AND OTHER FEDERAL;

IF (4 LE CLASS LE 5) & IND3 GE  10 AND IND3 LE  32 THEN _BI01 = 1; ELSE _BI01 = 0 ; * AGRIC, FORESTRY, FISHING;
IF (4 LE CLASS LE 5) & IND3 GE  40 AND IND3 LE  50 THEN _BI02 = 1; ELSE _BI02 = 0 ; * MINING;
IF (4 LE CLASS LE 5) & IND3 GE  60 AND IND3 LE  60 THEN _BI03 = 1; ELSE _BI03 = 0 ; * CONSTRUCTION;
IF (4 LE CLASS LE 5) & IND3 GE 100 AND IND3 LE 392 THEN _BI04 = 1; ELSE _BI04 = 0 ; * MANUFACTURING;
IF (4 LE CLASS LE 5) & IND3 GE 400 AND IND3 LE 472 THEN _BI05 = 1; ELSE _BI05 = 0 ; * TRANS, COMM, UTILITIES;
IF (4 LE CLASS LE 5) & IND3 GE 500 AND IND3 LE 571 THEN _BI06 = 1; ELSE _BI06 = 0 ; * WHOLESALE TRADE;
IF (4 LE CLASS LE 5) & IND3 GE 580 AND IND3 LE 691 THEN _BI07 = 1; ELSE _BI07 = 0 ; * RETAIL TRADE;
IF (4 LE CLASS LE 5) & IND3 GE 700 AND IND3 LE 712 THEN _BI08 = 1; ELSE _BI08 = 0 ; * FIRE;
IF (4 LE CLASS LE 5) & IND3 GE 721 AND IND3 LE 760 THEN _BI09 = 1; ELSE _BI09 = 0; * BUSINESS & REPAIR SERVICES;
IF (4 LE CLASS LE 5) & IND3 GE 761 AND IND3 LE 791 THEN _BI10 = 1; ELSE _BI10 = 0; * PERSONAL SERVICES;
IF (4 LE CLASS LE 5) & IND3 GE 800 AND IND3 LE 810 THEN _BI11 = 1; ELSE _BI11 = 0; * ENTERTAINMENT SERVICES;
IF (4 LE CLASS LE 5) & IND3 GE 812 AND IND3 LE 893 THEN _BI12 = 1; ELSE _BI12 = 0; * PROFESSIONAL & RELATED SERVICES;
*IF IND3 GE 900 AND IND3 LE 932 THEN _BI13 = 1; *ELSE _BI13 = 0 ; * PUBLIC ADMINISTRATION; * OMIT, INC IN PUBLIC;
END;

* SECTORAL VARIABLES ARE _BI01-_BI12 PUB_FED PUB_USPS PUV_STATE PUB_LOCAL NONPROFIT;
* LET MANUFACTURING BE OMITTED REFERENCE _BI04;
************************************************************************************;

*INDUSTRY AND SECTOR POST-2003;

IF YEAR GE 103 THEN DO;

IF CLASS=1 AND IND3 NE 6370 THEN PUB_FED=1; ELSE PUB_FED=0;
IF CLASS=1 AND IND3 EQ 6370 THEN PUB_USPS=1; ELSE PUB_USPS=0;
IF CLASS=2 THEN PUB_STATE=1; ELSE PUB_STATE=0;
IF CLASS=3 THEN PUB_LOCAL=1; ELSE PUB_LOCAL=0;
IF CLASS=5 THEN NONPROFIT=1; ELSE NONPROFIT=0;
PUB_FEDALL=PUB_FED+PUB_USPS; *COMBINE POSTAL AND OTHER FEDERAL;

IF (4 LE CLASS LE 5) & IND3 GE  170 AND IND3 LE  290 THEN _MI01 = 1; ELSE _MI01 = 0 ; *1  AGRICULTURE, FORESTRY, FISHING, AND HUNTING;
IF (4 LE CLASS LE 5) & IND3 GE  370 AND IND3 LE  490 THEN _MI02 = 1; ELSE _MI02 = 0 ; *2  MINING                                     ;
IF (4 LE CLASS LE 5) & IND3 GE  770 AND IND3 LE  770 THEN _MI03 = 1; ELSE _MI03 = 0 ; *3  CONSTRUCTION                               ;
IF (4 LE CLASS LE 5) & IND3 GE 1070 AND IND3 LE 3990 THEN _MI04 = 1; ELSE _MI04 = 0 ; *4  MANUFACTURING                              ;
IF (4 LE CLASS LE 5) & IND3 GE 4070 AND IND3 LE 5790 THEN _MI05 = 1; ELSE _MI05 = 0 ; *5  WHOLESALE AND RETAIL TRADE                 ;
IF (4 LE CLASS LE 5) & ((IND3 GE 6070 AND IND3 LE 6390) OR (IND3 GE 570 AND IND3 LE 690)) THEN _MI06 = 1; ELSE _MI06 = 0 ; *6  TRANSPORTATION AND UTILITIES;
IF (4 LE CLASS LE 5) & IND3 GE 6470 AND IND3 LE 6780 THEN _MI07 = 1; ELSE _MI07 = 0 ; *7  INFORMATION                                ;
IF (4 LE CLASS LE 5) & IND3 GE 6870 AND IND3 LE 7190 THEN _MI08 = 1; ELSE _MI08 = 0 ; *8  FINANCIAL ACTIVITIES                       ;
IF (4 LE CLASS LE 5) & IND3 GE 7270 AND IND3 LE 7790 THEN _MI09 = 1; ELSE _MI09 = 0 ; *9  PROFESSIONAL AND BUSINESS SERVICES         ;
IF (4 LE CLASS LE 5) & IND3 GE 7860 AND IND3 LE 8470 THEN _MI10= 1; ELSE _MI10 = 0; *10 EDUCATIONAL AND HEALTH SERVICES            ;
IF (4 LE CLASS LE 5) & IND3 GE 8506 AND IND3 LE 8690 THEN _MI11= 1; ELSE _MI11 = 0; *11 LEISURE AND HOSPITALITY                    ;
IF (4 LE CLASS LE 5) & IND3 GE 8770 AND IND3 LE 9290 THEN _MI12= 1; ELSE _MI12 = 0; *12 OTHER SERVICES                             ;
*IF IND3 GE 9370 AND IND3 LE 9590 THEN _MI13 = 1; *ELSE _MI13 = 0 ; *13 PUBLIC ADMINISTRATION; * OMIT, INC IN PUBLIC;
END;
* SECTORAL VARIABLES ARE _MI01-_MI12 PUB_FED PUB_USPS PUV_STATE PUB_LOCAL NONPROFIT;
* LET MANUFACTURING BE OMITTED REFERENCE _MI04;
************************************************************************************;
* SET OFF-PERIOD MISSINGS FROM YEAR-RESTRICTED DO-END STATEMENTS TO ZERO;
IF _BI01=. THEN _BI01=0; IF _BI02=. THEN _BI02=0; IF _BI03=. THEN _BI03=0; IF _BI04=. THEN _BI04=0;
IF _BI05=. THEN _BI05=0; IF _BI06=. THEN _BI06=0; IF _BI07=. THEN _BI07=0; IF _BI08=. THEN _BI08=0;
IF _BI09=. THEN _BI09=0; IF _BI10=. THEN _BI10=0; IF _BI11=. THEN _BI11=0; IF _BI12=. THEN _BI12=0;
IF _MI01=. THEN _MI01=0; IF _MI02=. THEN _MI02=0; IF _MI03=. THEN _MI03=0; IF _MI04=. THEN _MI04=0;
IF _MI05=. THEN _MI05=0; IF _MI06=. THEN _MI06=0; IF _MI07=. THEN _MI07=0; IF _MI08=. THEN _MI08=0;
IF _MI09=. THEN _MI09=0; IF _MI10=. THEN _MI10=0; IF _MI11=. THEN _MI11=0; IF _MI12=. THEN _MI12=0;

************************************************************************************;
* BROAD OCCUPATION DUMMIES USE SEPARATELY FOR PRE AND POST 2003;
* USE _MOCC VARIABLES FOR 2003+ ONLY AND _BOCC FOR PRE-2003;
* USE _BOCC13 PRE-2003 AS REFERENCE, HANDLERS,CLEANERS,LABORERS;

IF YEAR LE 102 & _BOCC= 1 THEN _BOCC01=1; ELSE _BOCC01=0; *EXECUTIVE, ADMINISTRATIVE, AND MANGERIAL           ;
IF YEAR LE 102 & _BOCC= 2 THEN _BOCC02=1; ELSE _BOCC02=0; *PROFESSIONAL SPECIALITY OCCUPATIONS                ;
IF YEAR LE 102 & _BOCC= 3 THEN _BOCC03=1; ELSE _BOCC03=0; *TECHNICIANS AND RELATED SUPPORT OCCUPATIONS        ;
IF YEAR LE 102 & _BOCC= 4 THEN _BOCC04=1; ELSE _BOCC04=0; *SALES OCCUPATIONS                                  ;
IF YEAR LE 102 & _BOCC= 5 THEN _BOCC05=1; ELSE _BOCC05=0; *ADMINISTRATIVE SUPPORT, INCLUDING CLERICAL         ;
IF YEAR LE 102 & _BOCC= 6 THEN _BOCC06=1; ELSE _BOCC06=0; *PRIVATE HOUSEHOLD                                  ;
IF YEAR LE 102 & _BOCC= 7 THEN _BOCC07=1; ELSE _BOCC07=0; *PROTECTIVE SERVICES                                ;
IF YEAR LE 102 & _BOCC= 8 THEN _BOCC08=1; ELSE _BOCC08=0; *SERVICE, EXCEPT PRIVATE HOUSEHOLD                  ;
IF YEAR LE 102 & _BOCC= 9 THEN _BOCC09=1; ELSE _BOCC09=0; *FARMING, FORESTRY, AND FISHING                     ;
IF YEAR LE 102 & _BOCC=10 THEN _BOCC10=1; ELSE _BOCC10=0; *PRECISION PRODUCTION, CRAFT, AND REPAIR OCCUPATIONS;
IF YEAR LE 102 & _BOCC=11 THEN _BOCC11=1; ELSE _BOCC11=0; *MACHINE OPERATORS, ASSEMBLERS, AND INSPECTORS      ;
IF YEAR LE 102 & _BOCC=12 THEN _BOCC12=1; ELSE _BOCC12=0; *TRANSPORTATION AND MATERIAL MOVING OCCUPATIONS     ;
IF YEAR LE 102 & _BOCC=13 THEN _BOCC13=1; ELSE _BOCC13=0; *HANDLERS, EQUIPMENT CLEANERS, HELPERS AND LABORERS ;
IF YEAR GE 103 & (  1 LE OCC3 LE  99) THEN _MOCC01=1; ELSE _MOCC01=0; *MANAGEMENT, BUSINESS, AND FINANCIAL OCCUPATIONS  ;
IF YEAR GE 103 & (100 LE OCC3 LE 369) THEN _MOCC02=1; ELSE _MOCC02=0; *PROFESSIONAL AND RELATED OCCUPATIONS             ;
IF YEAR GE 103 & (370 LE OCC3 LE 469) THEN _MOCC03=1; ELSE _MOCC03=0; *SERVICE OCCUPATIONS                              ;
IF YEAR GE 103 & (470 LE OCC3 LE 499) THEN _MOCC04=1; ELSE _MOCC04=0; *SALES AND RELATED OCCUPATIONS                    ;
IF YEAR GE 103 & (500 LE OCC3 LE 599) THEN _MOCC05=1; ELSE _MOCC05=0; *OFFICE AND ADMINISTRATIVE SUPPORT OCCUPATIONS    ;
IF YEAR GE 103 & (600 LE OCC3 LE 619) THEN _MOCC06=1; ELSE _MOCC06=0; *FARMING, FISHING, AND FORESTRY OCCUPATIONS       ;
IF YEAR GE 103 & (620 LE OCC3 LE 699) THEN _MOCC07=1; ELSE _MOCC07=0; *CONSTRUCTION AND EXTRACTION OCCUPATIONS          ;
IF YEAR GE 103 & (700 LE OCC3 LE 769) THEN _MOCC08=1; ELSE _MOCC08=0; *INSTALLATION, MAINTENANCE, AND REPAIR OCCUPATIONS;
IF YEAR GE 103 & (770 LE OCC3 LE 899) THEN _MOCC09=1; ELSE _MOCC09=0; *PRODUCTION OCCUPATIONS                           ;
IF YEAR GE 103 & (900 LE OCC3 LE 975) THEN _MOCC10=1; ELSE _MOCC10=0; *TRANSPORTATION AND MATERIAL MOVING OCCUPATIONS   ;

PROC MEANS DATA=RESPOND;

DATA RESPOND; SET RESPOND;
DROP HHID1 PKID0_17 H2_ HSINGLEM HEVERM HSINGLEF HEVERF INTERVIW GRADE COMPLETE
     PERTYPE MAJORACT DISCOURG WHYLOOK UNREASON WHYLEAVE YEAR2;

DATA ECO.RESPOND9808; SET RESPOND; * CREATE PERMANENT SAS DATA SET;
PROC MEANS DATA=ECO.RESPOND9808;

DATA ECO.M_RESPOND9808 ECO.F_RESPOND9808; SET RESPOND; * CREATE PERMANENT SAS DATA SETS FOR MEN-WOMEN;
IF FEMALE=0 THEN OUTPUT ECO.M_RESPOND9808; 
IF FEMALE=1 THEN OUTPUT ECO.F_RESPOND9808; 

PROC MEANS DATA=ECO.M_RESPOND9808; 
VAR PT RWAGE2 IMPUTE2 NSPOUSEPROX SPOUSEPROX FEB MARCH OTHERMONTH ED_ELEM SCH_9 SCH_10 SCH_11 SCH_12 ED_HS 
SCH_SOME ED_ASSOC SCH_BA SCH_MA SCH_PRO SCH_PHD EXP EXPSQ EXPCUB EXPQUAR _MSP _MNSP 
BLACK ASIAN OTHER HISPANIC FOR_NONCTZ FOR_CTZ SIZE1 SIZE2 SIZE3 SIZE4 SIZE5 SIZE6 SIZE7 
NE MA ENC WNC SA ESC WSC MT PAC PUB_FEDALL PUB_STATE PUB_LOCAL MEMBER 
_BI01-_BI12 _MI01-_MI12 _BOCC01-_BOCC13 _MOCC01-_MOCC10 YEAR98-YEAR108;
TITLE 'MALE MEANS ON SELECTED VARIABLES';

PROC MEANS DATA=ECO.F_RESPOND9808; 
VAR PT RWAGE2 IMPUTE2 NSPOUSEPROX SPOUSEPROX FEB MARCH OTHERMONTH ED_ELEM SCH_9 SCH_10 SCH_11 SCH_12 ED_HS 
SCH_SOME ED_ASSOC SCH_BA SCH_MA SCH_PRO SCH_PHD EXP EXPSQ EXPCUB EXPQUAR _MSP _MNSP 
BLACK ASIAN OTHER HISPANIC FOR_NONCTZ FOR_CTZ SIZE1 SIZE2 SIZE3 SIZE4 SIZE5 SIZE6 SIZE7 
NE MA ENC WNC SA ESC WSC MT PAC PUB_FEDALL PUB_STATE PUB_LOCAL MEMBER 
_BI01-_BI12 _MI01-_MI12 _BOCC01-_BOCC13 _MOCC01-_MOCC10 YEAR98-YEAR108;
TITLE 'FEMALE MEANS ON SELECTED VARIABLES';

PROC DELETE DATA=_ALL_;

RUN;
